package com.lianzheng.dao.impl;

import java.util.List;
import java.util.Map;
import java.util.HashMap;

import com.lianzheng.dao.TbDocArticleinfoDAO;
import com.lianzheng.model.TbDocArticleinfo;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.stereotype.Repository;


/**
 * This class interacts with Spring's IbatisTemplate to save/delete
 * <p>
 * <a href="TbDocArticleinfo.DAOimpl.java.html"><i>View Source</i></a>
 * </p>
 *
 * @author <a href="mailto:heymanchen@gmail.com">haihua chen</a>
*/
@Repository
public class TbDocArticleinfoDAOimpl extends SqlMapClientDaoSupport implements TbDocArticleinfoDAO {

    /**
     * @see com.lianzheng.dao.TbDocArticleinfoDAO#getTbDocArticleinfo($keytype)
     */

    public TbDocArticleinfo getTbDocArticleinfo(String id){
        return (TbDocArticleinfo)getSqlMapClientTemplate().queryForObject("getTbDocArticleinfo", id);
    }

    public TbDocArticleinfo getTbDocArticleinfoFull(String id){
        return (TbDocArticleinfo)getSqlMapClientTemplate().queryForObject("getTbDocArticleinfoFull", id);
    }

    public void addTbDocArticleinfo(final TbDocArticleinfo tbDocArticleinfo) {
        getSqlMapClientTemplate().update("addTbDocArticleinfo", tbDocArticleinfo);
    }

    public void updateTbDocArticleinfo(final TbDocArticleinfo tbDocArticleinfo) {
    getSqlMapClientTemplate().update("updateTbDocArticleinfo", tbDocArticleinfo);
    }

    public void removeTbDocArticleinfo(String id){
        getSqlMapClientTemplate().update("removeTbDocArticleinfo", id);
    }

    public List getTbDocArticleinfos() {
        return getSqlMapClientTemplate().queryForList("getTbDocArticleinfos",null);
    }

    public List getTbDocArticleinfoByAnd(final TbDocArticleinfo tbDocArticleinfo,String order_by){
        Map map = new HashMap();
        map.put(FIND_BY_AND, "True");
        if (order_by != null)
            map.put(ORDER_BY,order_by);
        tbDocArticleinfo.setMagic(map);
        return getSqlMapClientTemplate().queryForList("getTbDocArticleinfoByMap", tbDocArticleinfo);
    }

    public List getTbDocArticleinfoByOr(final TbDocArticleinfo tbDocArticleinfo,String order_by){
        Map map = new HashMap();
        map.put(FIND_BY_OR, "True");
        if (order_by != null)
            map.put(ORDER_BY,order_by);
        tbDocArticleinfo.setMagic(map);
        return getSqlMapClientTemplate().queryForList("getTbDocArticleinfoByMap", tbDocArticleinfo);
    }
    
    public List getTbDocArticleinfoByLike(final TbDocArticleinfo tbDocArticleinfo,String order_by){
        Map map = new HashMap();
        map.put(FIND_BY_LIKE, "True");
        if (order_by != null)
            map.put(ORDER_BY,order_by);
        tbDocArticleinfo.setMagic(map);
        return getSqlMapClientTemplate().queryForList("getTbDocArticleinfoByMap", tbDocArticleinfo);
    }
}